<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>scrollLeft/scrollTop</title>
		<style>
			#box {
				width: 100px;
				height: 100px;
				padding: 10px;
				border: 30px solid red;
				overflow-y: auto;
			}
		</style>
	</head>
	<body>
		<div id="box">
			Lorem ipsum, dolor sit amet consectetur adipisicing elit. Rerum molestias et repudiandae consequatur sit quod
			omnis, labore eum vero incidunt cumque commodi itaque officiis? Nemo exercitationem repellendus officiis dolorum
			soluta?
		</div>

		<br />

		<button onclick="hanlerClick()">元素滚动到指定位置</button>

		<script>
			// scrollLeft/scrollTop 获取和设置元素水平/垂直滚动位置

			hanlerClick = () => {
				// 0 或一个大的值，例如 1e9，将会使元素滚动到顶部/底部。
				box.scrollLeft = 50
				box.scrollTop = 50
				console.log(box.scrollLeft)
				console.log(box.scrollTop)
			}
		</script>
	</body>
</html>
